package com.rdxer.api;

import com.rdxer.core.entity.Result;
import com.rdxer.core.utils.search.SearchPara;
import com.rdxer.model.Notice;
import com.rdxer.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/notice")
public class NoticeApi {
    @Autowired
    NoticeService service;
    @RequestMapping("/getList")
    public Result<List<Notice>> getList(@AuthenticationPrincipal Principal principal){

        SearchPara para = new SearchPara();

        para.getWhere().put("enable",true);

        List<Notice> notices = service.searchNoPage(para);

        return Result.ofSucceed(notices);
    }
}
